<html>
<head>
<style>
A
{

	text-decoration: none; color: 003265;
}

A:hover
{

	text-decoration: underline; color: 000000;
}


td, body, input
{

	font-family: Trebuchet MS, Arial; font-size: 11px;
}


.headerLinks
{

	color: white; font-weight: bold;
}

.headerLinks:hover
{

	color: #FFFFFF;
}

input, textarea
{
	border: 1px solid; border-color: #BBBBBB; background-color: #F0F0F0;
}

textarea
{
	font-size: 12px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
function ClipBoard( area )
{
	holdtext.innerText = area.innerText;
	Copied             = holdtext.createTextRange();

	if ( Copied.execCommand("Copy") == true )
	{
		alert('Text copied to clipboard successfully');
	}
}

function openAddNoteWindow ( funcID )
{
	var w   = 500, h = 500;
	var top = ( screen.height - h ) / 2 - 15, left = ( screen.width - w ) / 2;

	if ( top < 0 )
	{
		top = 0;
	}

	if ( left < 0 )
	{
		left = 0;
	}

	window.open('index.php?a=addnote&f=' + funcID,
		    'AddNote',
		    'width=' + w + ',height=' + h + ',top=' + top + ', left=' + left + ',scrollbars=yes');
}
</SCRIPT>
<title>txtSQL Documentation Functions : grant_permissions</title>
</head>
<body bgcolor="FFFFFF" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">

<table width="100%" cellspacing="0" cellpadding="3"
	<tr bgcolor="003265">
		<td><font color="white"><b>grant_permissions</b></font></td>
		<td align="right">
			<a href="javascript:history.back()" class="headerLinks">Back</a>
			<font color="white"> | <a href="javascript:history.forward()" class="headerLinks">Forward</a> |
			<a href="index.html" class="headerLinks">Home</a>
		</td>
	</tr>
	<tr>
		<td height="8" background="shadow.gif" colspan="2">
		</td>
	</tr>
</table>
<br />

<table width="95%" cellspacing="1" cellpadding="3" align="center">
	<tr valign="top">
		<td width="125" style="border:1px solid; border-color: #BBBBBB" bgcolor="#FAFAFA">
			<a href="1.html">'Language Reference'</a><br />
			<br />

			<b><a href="13.html">User Functions</a></b><br />
			<li><a href="14.html">connect</a></li><br />
			<li><a href="15.html">disconnect</a></li><br />
			<li><b>grant_permissions</b></li><br />
			<li><a href="17.html">getUsers</a></li><br />
			<li><a href="18.html">version</a></li><br />
			<li><a href="50.html">query_count</a></li><br />
			<br />

			<a href="19.html">Database Functions</a><br />
			<br />

			<a href="28.html">Data Manipulation Functions</a><br />
			<br />

			<a href="34.html">Table Functions</a><br />
			<br />

			<a href="42.html">Error Handling Functions</a><br />

		<br />		</td>
		<td style="padding-left: 35px;">
			<table width="100%">
				<tr valign="bottom">
					<td align="left" width="33%"><< <a href="15.html">Last Section ( disconnect )</a></td>
					<td align="center" width="33%"><font size="6">grant_permissions</font></td>
					<td align="right" width="33%"><a href="17.html">Next Section ( getUsers )</a> >></td>
				</tr>
			</table>

			<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border:1px solid;border-color:#BBBBBB;">
				<tr bgcolor="#F4F4F4" align="left">
					<td width="75"><b>Usage</b></td>
					<td><i>void</i> grant_permissions ( $action, $username, $password [, $newpass] )</td>
				</tr>
				<tr bgcolor="#F4F4F4" align="left">
					<td width="75"><b>Purpose</b></td>
					<td>To work with the current txtSQL users</td>
				</tr>
				<tr bgcolor="#F4F4F4" align="left">
					<td width="75"><b>Availability</b></td>
					<td>txtSQL >= 2.0.0 Beta</td>
				</tr>
			</table>
			<BR />

			This function allows for the manipulation of <i>$user</i>; it can either add a user, drop, or edit a user.<br>
			<i>$action</i> can be one of either add, edit, or drop.<br /><br />
			
			<li>If it is 'add', then <i>$username</i> will be the new user's name, and <i>$password</i> will be his/her password<br>
			<li>If it is 'drop', then <i>$username</i> must be specified, and so does <i>$password</i> (password for this user).
			<li>If it is 'edit', then <i>$username</i> must be specified, along with <i>$password</i>, and <i>$newpass</i>. The new password would be
			<i>$newpass</i>.<br /><br />
			
			<b>Note</b>- If you are dropping, or editing a user, and the incorrect password is specified, OR when adding a user and the user already exists, then txtSQL will issue a warning and return <i>false</i>.<br />
			<b>Note</b>- You can never drop the user 'root'<br />
			<b>Note</b>- In txtSQL <= 2.2.0 Beta, setting an empty password would incorrectly save, do not set empty passwords before this.
			<br /><br/>


			<table width="100%" cellspacing="1" cellpadding="3">
				<tr>
					<td align="left"><b>Example 3: grant_permissions() to add user</b>
					<td align="right"><a href="javascript: ClipBoard(copytext1)">Copy to Clipboard</a></td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#F4F4F4" style="border: 1px solid; border-color: #BBBBBB" id="copytext1">
						<code><font color="#000000">
						<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// Add a user 'foo' with password 'bar' <br /></font><font color="#0000BB">$sql</font><font color="#007700">-&gt;</font><font color="#0000BB">grant_permissions</font><font color="#007700">(</font><font color="#DD0000">'add'</font><font color="#007700">, </font><font color="#DD0000">'foo'</font><font color="#007700">, </font><font color="#DD0000">'bar'</font><font color="#007700">)<br /></font><font color="#0000BB">?&gt;</font>
						</font>
						</code>
					</td>
				</tr>
			</table>
			<br />


			<table width="100%" cellspacing="1" cellpadding="3">
				<tr>
					<td align="left"><b>Example 4: grant_permissions() to drop user</b>
					<td align="right"><a href="javascript: ClipBoard(copytext2)">Copy to Clipboard</a></td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#F4F4F4" style="border: 1px solid; border-color: #BBBBBB" id="copytext2">
						<code><font color="#000000">
						<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// Drop a user 'foo' whose password is 'bar' <br /></font><font color="#0000BB">$sql</font><font color="#007700">-&gt;</font><font color="#0000BB">grant_permissions</font><font color="#007700">(</font><font color="#DD0000">'drop'</font><font color="#007700">, </font><font color="#DD0000">'foo'</font><font color="#007700">, </font><font color="#DD0000">'bar'</font><font color="#007700">)<br /></font><font color="#0000BB">?&gt;</font>
						</font>
						</code>
					</td>
				</tr>
			</table>
			<br />


			<table width="100%" cellspacing="1" cellpadding="3">
				<tr>
					<td align="left"><b>Example 5: grant_permissions() to edit user</b>
					<td align="right"><a href="javascript: ClipBoard(copytext3)">Copy to Clipboard</a></td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#F4F4F4" style="border: 1px solid; border-color: #BBBBBB" id="copytext3">
						<code><font color="#000000">
						<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// Edit a user 'foo' whose password is 'bar', and change the password to 'foobar' <br /></font><font color="#0000BB">$sql</font><font color="#007700">-&gt;</font><font color="#0000BB">grant_permissions</font><font color="#007700">(</font><font color="#DD0000">'edit'</font><font color="#007700">, </font><font color="#DD0000">'foo'</font><font color="#007700">, </font><font color="#DD0000">'bar'</font><font color="#007700">, </font><font color="#DD0000">'foobar'</font><font color="#007700">)<br /></font><font color="#0000BB">?&gt;</font>
						</font>
						</code>
					</td>
				</tr>
			</table>
			<br />


			<TEXTAREA ID="holdtext" STYLE="display:none;"></TEXTAREA>

			<table width="100%" cellspacing="1" cellpadding="3" border="0" bgcolor="D0D0D0" align="center">
				<tr>
					<td><font size="1">User-Contributed Comments for: </font><br><b>grant_permissions()</b></td>
					<td align="right" valign="top"><a href="javascript: openAddNoteWindow('16');"> <font size="1" style="text-decoration:underline;"></font></a></td>
				</tr>
				<tr>
					<td bgcolor="#E0E0E0" colspan="2">
						<b>FarazAli</b> <font size="1">&lt;Faraz87 at comcast dot net&gt;<br />
						July 30, 2004, 11:19 pm</font>
						<table width="100%" cellspacing="0" cellpadding="3">
							<tr>
								<td bgcolor="#F0F0F0">
									<font face="courier new" size="3"><code><font color="#000000">
Passwords are automatically encrypted by txtSQL using the md5() hashing method, so there is no need to encrypt the password before hand.</font>
</code></font>								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<br />

</body>
</html>